﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kokomo.Mirror.CliMetadata.Tables
{
	public class TypeRefRow : IMetadataRow
	{
		[CodedIndex(CodedIndexType.ResolutionScope)]
		public CodedIndex ResolutionScope { get; set; }

		public StringRef TypeName { get; set; }
		public StringRef TypeNamespace { get; set; }

		public string GetFullName(MetadataContainer container)
		{
			string name = container.GetString(this.TypeName);
			string ns = container.GetString(this.TypeNamespace);

			string fullName;
			fullName = (ns != null) ? ns + "." + name : name;

			return fullName;
		}
		public override string ToString(MetadataContainer container)
		{
			string fullName = this.GetFullName(container);
			IMetadataRow scope = container.GetRow(this.ResolutionScope);
			if (scope != null)
			{
				fullName += " [" + scope.ToString(container) + "]";
			}

			return fullName;
		}
	}
}
